#ifndef __VZ_LOG_H__
#define __VZ_LOG_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "log_id_def.h"
#include "elog.h"

#define MAX_RECORD_LOG_LEN (200 * sizeof(LogInfo_t))
#define MAX_FILE_LOG_LEN (2000 * sizeof(LogInfo_t))

#ifndef LOG_TRACE_SYS
#define LOG_TRACE_SYS(LOG_LEVEL, LOG_ID, format, ...) \
  VzLog_Output(LT_SYS, LOG_LEVEL, LOG_ID, format, ##__VA_ARGS__);\
  log_w(format, ##__VA_ARGS__);
#endif

#ifndef LOG_TRACE_DEV
#define LOG_TRACE_DEV(LOG_LEVEL, LOG_ID, format, ...) \
  VzLog_Output(LT_DEV, LOG_LEVEL, LOG_ID, format, ##__VA_ARGS__);\
  log_w(format, ##__VA_ARGS__);
#endif

#ifndef LOG_TRACE_UI
#define LOG_TRACE_UI(LOG_LEVEL, LOG_ID, format, ...) \
  VzLog_Output(LT_UI, LOG_LEVEL, LOG_ID, format, ##__VA_ARGS__);\
  log_w(format, ##__VA_ARGS__);
#endif

#ifndef LOG_TRACE_POINT
#define LOG_TRACE_POINT(LOG_LEVEL, LOG_ID, format, ...) \
  VzLog_Output(LL_INFO, LOG_LEVEL, LOG_ID, format, ##__VA_ARGS__);\
  log_w(format, ##__VA_ARGS__);
#endif

#define LOG_MAX_LOG_COUNT (100000)
#define LOG_MAX_SERVICE_LEN (4)
#define LOG_MAX_DATA_LEN (32)

typedef struct LogInfo_ {
  uint8_t type;
  uint8_t level;
  uint16_t log_id;
  uint64_t log_time;
  char data[LOG_MAX_DATA_LEN];
} LogInfo_t;

typedef enum {
  LT_DEBUG = 0x01,
  LT_POINT = 0x02,
  LT_SYS = 0x04,  
  LT_DEV = 0x08,  
  LT_UI = 0x10,   
  LT_USER1 = 0x20,
  LT_USER2 = 0x40,
  LT_USER3 = 0x80,
} LOG_TYPE_E_ITEM;

typedef enum {
  LL_DEBUG = 0,
  LL_INFO,
  LL_WARNING,
  LL_ERROR,
  LL_KEY, 
  LL_NONE,
} LOG_LEVEL_E;

typedef enum {
  TAG_DEVICE_LOG = 0,
  TAG_HEARTBEAT,
  TAG_MONITOR,
  TAG_EVENT,
  TAG_BUSINESS,
} LOG_TAG_T;

int32_t VzLog_Init();

int32_t VzLog_Flush();

int32_t VzLog_Uninit();

int32_t VzLog_WriteCache(char *data, int32_t size);

int32_t VzLog_GetCache(char *buffer,uint32_t buff_size, uint32_t log_start, uint32_t log_count);

void VzLog_Output(int32_t type, int32_t level, int32_t log_id, const char *format, ...);

int32_t VzLog_DumpCache();

uint32_t VzLog_GetNewCount();

uint32_t VzLog_GetTotalCount();

void VzLog_ResetCount();

int32_t VzLog_Read(int type, char *buff, uint32_t buff_size,
                     uint32_t start, uint32_t count);

void VzLog_Clear();
#ifdef __cplusplus
}
#endif

#endif //__VZ_LOG_H__
